namespace Aurora.TaskScheduler.Abstractions.Message;

/// <summary>
/// app task
/// </summary>
public class AppTask
{
    /// <summary>
    /// 任务名
    /// </summary>
    public string TaskName { get; set; }

    /// <summary>
    /// 分组名
    /// </summary>
    public string GroupName { get; set; }

    /// <summary>
    /// 间隔时间
    /// </summary>
    public string Interval { get; set; }

    /// <summary>
    /// 间隔时间的描述
    /// </summary>

    public string IntervalDescription { get; set; }

    /// <summary>
    /// 调用的API地址
    /// </summary>
    public string ApiUrl { get; set; }

    /// <summary>
    /// 任务描述
    /// </summary>
    public string Describe { get; set; }

    /// <summary>
    /// 最近一次运行时间
    /// </summary>
    public DateTime? LastRunTime { get; set; }

    /// <summary>
    /// 运行状态
    /// </summary>
    public int Status { get; set; }

    /// <summary>
    /// 任务类型(1.DLL类型,2.API类型)
    /// </summary>
    public int TaskType { get; set; }

    #region Api类型专用参数

    /// <summary>
    /// API访问类型(API类型)
    /// </summary>
    public string ApiRequestType { get; set; }

    /// <summary>
    /// 授权名(API类型)
    /// </summary>
    /// 
    public string ApiAuthKey { get; set; }

    /// <summary>
    /// 授权值(API类型)
    /// </summary>
    /// 
    public string ApiAuthValue { get; set; }

    /// <summary>
    /// API参数
    /// </summary>
    /// 
    public string ApiParameter { get; set; }

    #endregion

    #region DLL类型专用参数

    /// <summary>
    /// DLL类型名
    /// </summary>
    /// 
    public string DllClassName { get; set; }

    /// <summary>
    /// Dll方法名
    /// </summary>
    /// 
    public string DllActionName { get; set; }

    /// <summary>
    /// 参数类型名称
    /// </summary>
    public string ArgumentTypeName { get; set; }

    #endregion

    /// <summary>任务编号</summary>
    public string Id { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public string CreatedTime { get; set; }

    /// <summary>
    /// 最后修改时间
    /// </summary>
    public string LastModifiedTime { get; set; }

    /// <summary>
    /// 任务类型(1.DLL类型,2.API类型)
    /// </summary>
    public string TaskTypeName
    {
        get
        {
            switch (TaskType)
            {
                case 1: return "DLL";
                case 2: return "API";
                default: return "";
            }
        }
    }


    /// <summary>
    /// 任务执行类型 CRON 代表周期性  ONE 代表只执行一次  执行一次之后 就自动删除
    /// </summary>
    public string TaskExecuteType { get; set; } = "CRON";


    /// <summary>
    /// 状态名称
    /// </summary>
    public string StatusName
    {
        get
        {
            switch (Status)
            {
                case 1:
                    return "新增";
                case 2:
                    return "删除";
                case 3:
                    return "修改";
                case 4:
                    return "暂停";
                case 5:
                    return "停止";
                case 6:
                    return "开启";
                case 7:
                    return "立即执行";
                default:
                    return "";
            }
        }
    }

    /// <summary>
    /// 下一次运行时间
    /// </summary>
    public DateTime? NextRunTime { get; set; }
}